package net.ibizsys.eclipse.studio.tree;

import java.util.ArrayList;
import java.util.List;

/**
 * 树节点数据
 * 
 * @author <a href='http://www.weibo.com/xjtoo' target='_blank'>Enmaai</a>
 */
public class IBizTreeNode
{
	private IBizTreeNode parent;
	private boolean rootNode;

	private String icon;
	private String text;
	private String desc;

	private IIBizTreeData data;

	private List<IBizTreeNode> children = new ArrayList<IBizTreeNode>();

	/**
	 * 
	 * @param text 标题
	 */
	public IBizTreeNode()
	{
	}

	/**
	 * 
	 * @param text 标题
	 */
	public IBizTreeNode(String text)
	{
		this(null, text, null, null);
	}

	/**
	 * 
	 * @param text 标题
	 * @param icon 图标
	 */
	public IBizTreeNode(String text, String icon)
	{
		this(null, text, icon, null);
	}

	/**
	 * 
	 * @param text 标题
	 * @param icon 图标
	 * @param desc 描述
	 */
	public IBizTreeNode(String text, String icon, String desc)
	{
		this(null, text, icon, desc);
	}

	/**
	 * 
	 * @param data 真实数据
	 */
	public IBizTreeNode(IIBizTreeData data)
	{
		this(data, null, null, null);
	}

	/**
	 * 
	 * @param data 真实数据
	 * @param text 标题
	 */
	public IBizTreeNode(IIBizTreeData data, String text)
	{
		this(data, text, null, null);
	}

	/**
	 * 
	 * @param data 真实数据
	 * @param text 标题
	 * @param icon 图标
	 */
	public IBizTreeNode(IIBizTreeData data, String text, String icon)
	{
		this(data, text, icon, null);
	}

	/**
	 * 
	 * @param data 真实数据
	 * @param text 标题
	 * @param icon 图标
	 * @param desc 描述
	 */
	public IBizTreeNode(IIBizTreeData data, String text, String icon, String desc)
	{
		this.data = data;
		this.text = text;
		this.icon = icon;
		this.desc = desc;
	}

	public String getIcon()
	{
		if (icon == null && data != null)
		{
			return data.getIcon();
		}

		return icon;
	}

	public String getText()
	{
		if (text == null && data != null)
		{
			return data.getText();
		}
		return text;
	}

	public String getDesc()
	{
		if (desc == null && data != null)
		{
			return data.getDesc();
		}
		return desc;
	}

	public void setIcon(String icon)
	{
		this.icon = icon;
	}

	public void setText(String text)
	{
		this.text = text;
	}

	public void setDesc(String desc)
	{
		this.desc = desc;
	}

	public void addChild(IBizTreeNode node)
	{
		children.add(node);
	}

	public List<IBizTreeNode> getChildren()
	{
		return children;
	}

	public IIBizTreeData getData()
	{
		return this.data;
	}

	public void setData(IIBizTreeData data)
	{
		this.data = data;
	}

	public IBizTreeNode getParent()
	{
		return parent;
	}

	public void setParent(IBizTreeNode parent)
	{
		this.parent = parent;
	}

	public boolean isRootNode()
	{
		return rootNode;
	}

	public void setRootNode(boolean rootNode)
	{
		this.rootNode = rootNode;
	}
}
